package com.easybuy.service.OrderService;

import com.easybuy.Tools.Page;
import com.easybuy.Tools.Wares;
import com.easybuy.dao.OrderMapper;
import com.easybuy.pojo.Order;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;


    public Page getOrder(Map map) {
        Page page=(Page) map.get("page");
        page.setPageCount(orderMapper.getOrderCount(map));
        List list=orderMapper.getOrder(map);
        page.setList(list);
        return page;
    }
    public Map addOrder(Order order){
        Map map=new HashMap();
        if (orderMapper.addOrder(order)>0){
            List<Order> list=orderMapper.returnOrder();
            Order order1=list.get(0);
            map.put("orderId",order1.getId());
            map.put("serialNumber",order1.getSerialNumber());
            return map;
        }else return null;
    }
    public int addOrderProduct(Wares wares){
        return orderMapper.addOrderProduct(wares);
    }

}
